//
//  UIBarButtonItem+Extention.swift
//  weibo
//
//  Created by 李海超 on 2017/5/21.
//  Copyright © 2017年 lihaichao. All rights reserved.
//

import UIKit













extension UIBarButtonItem{

    /**
     便利方法，如果参数中设置有默认值，调用时如果不需要该参数，可以省略

     - parameter isBack:   判断是否是返回按钮
    */
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject?,action:Selector,isBack:Bool = false) {
        
        
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        
        if isBack {
            
            let name = "navigationbar_back_withtext"
            
            btn.setImage(UIImage(named:name), for: UIControlState(rawValue:0))
            
            btn.setImage(UIImage(named:name+"_highlighted"), for: .highlighted)
        }
        
        btn.sizeToFit()
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView:btn)
    }
    
}
